<?php

function sendVerifyEmail_helper($email) {
    $object =& get_instance();    
    $object->load->library('email');
    $object->load->helper('file');
    $object->load->model('user_model');
    
    $userinfo = $object->user_model->getUserInfo($email);
    $link = $object->config->item('base_url').'security/verifyEmailAndCode/'
            .$userinfo['user_id'].'/'.$object->user_model->getVerifyEmailHash($email);
    $object->email->from('no-reply@eyesbridge.com', '眼缘网');
    $object->email->to($email);
    $object->email->subject('眼缘网 | 欢迎注册，请您验证您的邮箱');
    $path = $object->config->item('server_root');
    $file = $path.'assets/templates/verifyemail.html';
    
    $content = read_file($file);
    $content_edited = str_replace(array('{nickname}', '{link}'),
        array($userinfo['nickname'], $link),
        $content);
    $object->email->message($content_edited);
    $object->email->send();
}

function send_findpwd_email_helper($email, $originseed) {
    $object =& get_instance();    
    $object->load->library('email');
    $object->load->helper('file');
    $object->load->model('user_model');
    
    $userinfo = $object->user_model->getUserInfo($email);
    $link = $object->config->item('base_url').'security/find_pwd_verify/'
            .md5($originseed);
    $object->email->from('no-reply@eyesbridge.com', '眼缘网');
    $object->email->to($email);
    $object->email->subject('眼缘网 | 密码重置');
    $path = $object->config->item('server_root');
    $file = $path.'assets/templates/findpwdemail.html';
    
    $content = read_file($file);
    $content_edited = str_replace(array('{nickname}', '{link}'),
        array($userinfo['nickname'], $link),
        $content);
    $object->email->message($content_edited);
    $object->email->send();
}

?>
